
local mt = ac.skill['冲击波']
mt.art = [[ReplaceableTextures\CommandButtons\BTNCrushingWave.blp]]
mt.target_type = 2
mt.range = 700
mt.cool = 8
mt.damage = 100         --造成伤害
mt.damage_type = '魔法' --伤害类型
mt.start_area = 150
mt.final_area = 300

--投射物模型
mt.targetArt = [[Abilities\Spells\Other\CrushingWave\CrushingWaveDamage.mdl]]
mt.missile_art = [[Abilities\Spells\Other\CrushingWave\CrushingWaveMissile.mdl]]
mt.missile_speed = 1050   --投射物速度
mt.missile_height = 0
mt.missile_accel = 0
mt.distance = 800

function mt:on_cast_shot()
    local hero = self.owner
    local target = self.target
    local angle = hero:get_point()/target:get_point()
    self:shot_missile(angle)
end

function mt:shot_missile(angle,group)
    local hero = self.owner
    local start = hero:get_point()
    local ex_area = (self.final_area - self.start_area) / (self.distance / self.missile_speed)
    self.group = group or {}
    ac.mover('line'){
        start = start,
        angle = angle,
        model = self.missile_art,
        speed = self.missile_speed,
        height = self.missile_height,
        accel = self.missile_accel,
        distance = self.distance,
        on_move = function(_,point)
            self.start_area = self.start_area + ex_area * 0.03
            if self.damage>0 then
                for u in ac.selector('unit')
                    : range(point,self.start_area)
                    : enemy(hero)
                    : loop()
                do
                    local range = u:get_point() * start
                    if not self.group[u] and range<=self.start_area+50 then
                        self.group[u] = true
                        u:damage{
                            damage_type = self.damage_type,
                            source = hero,
                            damage = self.damage,
                            skill = self,
                        }
                        self:notify('on_hit',u)
                    end
                end
            end

        end,
        on_finish = function(mover)
            self:notify('on_finish',mover)
        end
    }
end

